#ifndef MPHTTPCLIENTIMPL_H
#define MPHTTPCLIENTIMPL_H


/*****************************************
 * HttpClientImpl 继承于 HttpClient
 *****************************************/

#include "mpHttpClient.h"
#include "mpHttpConnectionManage.h"

namespace MP{
namespace HTTP{
namespace INTERNAL{

class HttpClientImpl : public HttpClient
{
public:
    HttpClientImpl();
    ~HttpClientImpl() override;
public:

    virtual void send(HttpRequestMessage::ptr_s httpRequest,
                      HttpResponseMessage::ptr_s httpResponse,
                      func_send_progress_callback&& progress_callback = nullptr) override;

    //head
    virtual HttpResponseMessage::ptr_s head(const std::string& relativeUri,
                                            func_send_progress_callback&& progress_callback = nullptr) override;

    //get
    virtual HttpResponseMessage::ptr_s get(const std::string& relativeUri,
                                           func_send_progress_callback&& progress_callback = nullptr) override;

    virtual bool getStream(const std::string& relativeUri,
                           std::stringstream& stream,
                           func_send_progress_callback&& progress_callback = nullptr) override;

    virtual bool download(const std::string& relativeUri,
                          const std::string& filePath,
                          std::size_t fileOffset = 0,
                          func_send_progress_callback&& progress_callback = nullptr) override;

    //post
    virtual HttpResponseMessage::ptr_s post(const std::string& relativeUri,
                                            HttpRequestContent::ptr_s content,
                                            func_send_progress_callback&& progress_callback = nullptr) override;
    //put
    virtual HttpResponseMessage::ptr_s put(const std::string& relativeUri,
                                           HttpRequestContent::ptr_s content,
                                           func_send_progress_callback&& progress_callback = nullptr) override;
    //delete
    virtual HttpResponseMessage::ptr_s del(const std::string& relativeUri,
                                           func_send_progress_callback&& progress_callback = nullptr) override;

private:
    boost::asio::io_context _io_context;
    HttpConnectionManage::ptr_s _httpConnectionManage;

};

}   //INTERNAL
}   //HTTP
}   //MP


#endif // MPHTTPCLIENTIMPL_H
